let getRecorderManager = uni.getRecorderManager()
	
let ManagerStatus = true;
var url = '';
getRecorderManager.onStop((stop) => {
    // console.log(JSON.stringify(stop))
    const file = JSON.stringify(stop)
    ManagerStatus = true
    url = file.tempFilePath;
	// console.log('onnnnnnnnnStop',stop.tempFilePath);
	url = stop.tempFilePath;
    return stop.tempFilePath
})

getRecorderManager.onInterruptionEnd((stop) => {
    getRecorderManager.resume()
})

const startManager = ( ) => {
    if(ManagerStatus){
        ManagerStatus = false
        getRecorderManager.start({
            duration:600000,
            sampleRate:16000,
        })
    }
}

const stopManager = ( ) => {
	return new Promise((resolve,reject) => {
		getRecorderManager.stop()
		// console.log('urlurlulr',url,getRecorderManager);
		const interval  = setInterval(() => {
			if (url) {
				clearInterval(interval);
				resolve(url);
			}
		},100);
	})
}

export default {
	startManager,
	stopManager,
	url
}